Over the last week we’ve been taking a journey through ways to think differently about how to code the Look-and-Say sequence using some code examples. Today, we continue that journey through the eyes of a Scala enthusiast.
Ricky’s submission was the unique Scala submission. It has recursive, regular expression, and non-recursive solutions. It demonstrates use of a left-fold operation — one of a number of functional language operations not currently available in the Java 7 standard libraries. This being the version that most, if not all of us, use on project. However, some higher-order functions, including a variation of the left fold, are available in Java 8 and I’m sure we all look forward to the day when we can use these features from 9-5!
Take a look at Ricky’s code…